import Vue from 'vue'
import Vuex from 'vuex'
import persisted from 'vuex-persistedstate'

Vue.use(Vuex)
Vue.use(persisted)

export default new Vuex.Store({
  state: {
    user: {},
    showtop: true,
  },
  mutations: {
    userchange(state, obj) {
      state.user = obj;
      if (obj.type == 'logout') {
        state.user = []
      }
    },
    changeshow(state, obj) {
      if (obj.type == 'init') {
        state.showtop = obj.flag
      } else if (obj.type == 'login') {
        state.showtop = obj.flag
      }
    }
  },
  actions: {},
  modules: {},
  plugins: [persisted()]
})